<template>
  <el-tree
    :data="treeData"
    :props="defaultProps"
    accordion
    @node-click="handleNodeClick">
  </el-tree>
</template>

<script>
  export default {
    data() {
      return {
        treeData:[],
        defaultProps: {
          children: 'children',
          label: 'name'
        }
      };
    },
    mounted: function () {
      this.initMenu();
    },
    methods: {
      handleNodeClick(data) {
        console.log(data);
      },
      initMenu() {
        var _this = this;
        this.getRequest("/allMenu").then(resp=> {
          _this.loading = false;
          if (resp && resp.status == 200) {
            _this.treeData = resp.data;
          }
        })
      }
    },

  };
</script>

<style scoped>

</style>
